#include <rclcpp/rclcpp.hpp>
#include <geometry_msgs/msg/twist.hpp>
#include <rosbag2_cpp/reader.hpp>
class SimpleBagPlayNode: public rclcpp::Node
{
private:
    std::shared_ptr<rosbag2_cpp::Reader> reader_my;
public:
    SimpleBagPlayNode():Node("simple_bag_play_node")
    {
        RCLCPP_INFO(this->get_logger(),"SimpleBagPlayNode创建");
        this->reader_my = std::make_unique<rosbag2_cpp::Reader>();
        reader_my->open("my_bag");
        while (reader_my->has_next())
        {
           geometry_msgs::msg::Twist twist=reader_my->read_next<geometry_msgs::msg::Twist>();
           RCLCPP_INFO(this->get_logger(),"线速度=%.2f  角速度=%.2f",
            twist.linear.x,twist.angular.z
           );
        }
        reader_my->close();
    }
};
int main(int argc, char ** argv)
{
    rclcpp::init(argc,argv);
    rclcpp::spin(std::make_shared<SimpleBagPlayNode>());
    rclcpp::shutdown();
    return 0;
}